package com.userfactssample.client.client.framework.event;

import com.userfactssample.client.client.framework.UMComponent;
import com.userfactssample.client.client.framework.handler.UMActionHandler;

public class UMActionEvent extends UMClientEvent<UMActionHandler> {
	private static final Type<UMActionHandler> TYPE = new Type<UMActionHandler>();

	private UMComponent eventSource;
	
	private boolean cancel;

	public UMActionEvent(UMComponent eventSource) {
		super("ClientAction");
		this.eventSource = eventSource;
	}

	public UMComponent getEventSource() {
		return eventSource;
	}

	@Override
	protected void dispatch(UMActionHandler handler) {
		handler.onAction(this);
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<UMActionHandler> getAssociatedType() {
		return TYPE;
	}

	public void cancel() {
		cancel = true;
	}

	/**
	 * @return true if cancelled
	 */
	public boolean isCancelled() {
		return cancel;
	}
}
